const mongoose = require('mongoose')
const userSchema = new mongoose.Schema({
    email: {
        type: String,
        maxlength: 30,
        minlength: 4,
        required: [true, "填写邮箱"]
    },
    username: {
        type: String,
        maxlength: 20,
        minlength: 2,
        required: [true, "填写姓名"]
    },
    password: {
        type: String,
        maxlength: 1000,
        minlength: 4,
        required: [true, '填写密码']
    },
    registerDate: {
        type: Date,
        default: Date.now //默认值
    }
})

// 创建集合
const User = mongoose.model('User', userSchema);

// 将用户集合做为模块成员进行导出
module.exports = {
    User
}